package mylab.usm.oauth2.client.controller;

import com.fujieid.jap.core.config.AuthenticateConfig;
import com.fujieid.jap.oauth2.OAuthConfig;
import com.fujieid.jap.oauth2.Oauth2ResponseType;
import mylab.usm.oauth2.client.config.AuthProperties;
import mylab.usm.oauth2.client.config.AuthStrategy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用第三方OAuth2.0服务之隐藏式模式（适用于纯前端模式）
 * 需要依赖 jap-oauth2 模块
 */
@RestController
@RequestMapping("/oauth2/implicit")
public class Oauth2ImplicitController extends BaseOAuth2Controller {

    @Override
    protected AuthStrategy getAuthStrategy() {
        return AuthStrategy.oauth2_implicit;
    }

    @Override
    protected AuthenticateConfig getAuthenticateConfig(AuthProperties.Platform platform) {
        OAuthConfig config = (OAuthConfig) super.getAuthenticateConfig(platform);

        // 修改 ResponseType 为 Token 模式
        config.setResponseType(Oauth2ResponseType.TOKEN);
        return config;
    }
}
